<template>
	<view>
 		<u-modal :show="show" width="638rpx" confirmColor="#0762FF" :showConfirmButton="showBtn">
			<view class="slot-content">
				<image src="../static/bangdingshangji_slices/guanbi(1).png" mode="" @click="show = false"></image>
				<view class="title">
					{{$data.$language.mtitle}}
				</view>
				<!-- <rich-text :nodes="content"></rich-text> -->
				<input class="code" v-model="codes" :placeholder="$data.$language.recommender">
					
				</input>
				<!-- <view class="notice">
					{{$data.$language.mnotice}}
				</view> -->
				<view class="btn" @click="tui">
					{{$data.$language.btnE}}
				</view>
			</view>
		</u-modal>
 	</view>
</template>

<script>
import zhCN from '@/locales/zh-CN.js'
import enUS from '@/locales/en-US.js'
	import trCN from '@/locales/tr-CN.js'
	import {
		getBind,
		getUser
	} from '@/api/index.js';
export default {
	
     	data() {
     		return {
				$language:uni.getStorageSync('locale')=='en-US'? enUS:zhCN,
     			show:true,
				// mo:uni.setStorage('show'),
				showBtn:false,	
				codes:'',
     		};
     	},
		props:["msg"],
		created() {
			var translate = uni.getStorageSync('locale')
			if (translate == 'en-US') {
				this.$data.$language = enUS
			} else if (translate == 'zh-CN') {
				this.$data.$language = zhCN
			} else {
				this.$data.$language = trCN
			}
		},
		onLoad() {
			this.loadData()
			console.log(this.show,'fghjk');
		},
		methods:{		
			refreshLanguage(locale) {				
			      if (locale === 'zh-CN') {
			        this.$language = zhCN					
			      } else if (locale === 'en-US') {
			        this.$language = enUS
			      }else{
					  this.$data.$language = trCN
				  }			  
			},
			tui(){
				console.log(this.codes,'data');
				getBind({
					url:this.codes
				},
					(data) => {
						// 处理成功返回的数据
						console.log(data, 'data')
						this.show = false
						uni.showToast({
							title:'绑定成功',
							icon:"none",
							duration:2000
						})
						// uni.setStorageSync('token', data.userinfo.token)
					},
					(errorMsg) => {
						// 处理请求失败或错误的情况
						console.error(errorMsg);
					}
				)
			},
			loadData(){
				getUser(
					(data) => {
						// 处理成功返回的数据
						console.log(data, 'data')
						// uni.setStorageSync('token', data.userinfo.token)
					},
					(errorMsg) => {
						// 处理请求失败或错误的情况
						console.error(errorMsg);
					}
				)
			},
			
		}
     };
</script>

<style scoped>
.slot-content image{
	height: 34rpx;
	width: 34rpx;
	margin: 0 0 0 540rpx;
}
.title{
	width: 376rpx;
	height: 50rpx;
	font-size: 32rpx;
	font-family: PingFangSC-Semibold, PingFang SC;
	font-weight: 600;
	color: #2C2C2C;
	line-height: 50rpx;
	margin: 6rpx 0 60rpx 100rpx;
	text-align: center;
}
.code{
	width: 574rpx;
	height: 104rpx;
	background: #F4F6FA;
	border-radius: 16rpx;
	line-height: 104rpx;
	font-size: 28rpx;
	text-align: center;
	margin: 32rpx 0 0 16rpx;
}
.notice{
	width: 574rpx;
	height: 65rpx;
	font-size: 24rpx;
	font-family: PingFangSC-Regular, PingFang SC;
	font-weight: 400;
	color: #939393;
	line-height: 34rpx;
	margin: 16rpx 0 0 26rpx;
}
.btn{
	width: 574rpx;
	height: 100rpx;
	background: #0762FF;
	border-radius: 16rpx;
	margin: 120rpx 0 0 16rpx;
	text-align: center;
	line-height: 100rpx;
	color: #FFFFFF;
	font-weight: 600;
}
</style>

